package com.example.demo.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @author zhangjiawen
 * @Date: 2021/3/8 17:30
 */
@Api(tags = "首页模块")
@RestController
public class IndexController {

    @ApiImplicitParam(name = "name",value = "姓名",required = true)
    @ApiOperation(value = "向客人问好")
    @GetMapping("/sayHi")
    public ResponseEntity<String> sayHi(@RequestParam(value = "name")String name){
        return ResponseEntity.ok("Hi:"+name);
    }



 /*   public static void main(String[] args) throws ParseException {
        Calendar calendar=Calendar.getInstance();
        SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String string="2021-01-01 20:00:00";
        Date parse = sdf.parse(string);

        calendar.setTime(parse);

        Calendar calendar1=Calendar.getInstance();
        int day1 = calendar.get(Calendar.DAY_OF_YEAR);//第335天
        System.out.println(day1);
        int day2 = calendar1.get(Calendar.DAY_OF_YEAR);//第365天
        System.out.println(day2-day1);
    }*/

/*    public static void main(String[] args) {
        String string="postman 1、POST方法； 2、Body-form-data,key为后台方法的参数名，本例中因为importNumberSpaceData(MultipartFile file)，故key=file，value可以选择要上传的文件. 3、http://localhost:xxxx/importNumberSpaceData，Send. 4、如下图所示：";

        int postman = string.indexOf("postman");
        System.out.println(postman);
       String preStr=string.substring(0,postman);
        System.out.println(preStr);


       // String regEx = "[ _`~!@#$%^&*()+=|{}':;',\\[\\].<>/?~！@#￥%……&*（）——+|{}【】‘；：”“’。，、？]|\n|\r|\t";
        String regEx = "[ ({:;,.<?！……（{【‘；：”“。，？《]|\n|\r|\t";
        Pattern p = Pattern.compile(regEx);
        Matcher m = p.matcher(preStr);
        int lastone=0;
        while (m.find()){
            lastone=m.start();
        }
        System.out.println(lastone);
        System.out.println(string.substring(lastone,string.length()));

    }*/

}
